package greddy;

public class _05_55_跳跃游戏 {
    public static boolean canJump(int[] nums) {
    	int index = 0;
    	
    	if(nums.length == 1) {
    		return true;
    	}
    	// 只统计跳跃能覆盖的范围，覆盖的范围包含了终点，则能跳到终点
    	for(int i = 0; i <= index; i++) {
    		if(i + nums[i] > index) {
    			index = i + nums[i];
    		}
    		
    		if(index >= nums.length - 1) {
    			return true;
    		}
    	}
    	
    	return false;
    }
    
    public static void main(String[] args) {
		int[] nums = {2,5,0,0};
		System.out.println(canJump(nums));
	}
}
